<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link href="${pageContext.request.contextPath}/statics/Widget/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <!--[if IE 7]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/font-awesome-ie7.min.css" />
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/typeahead-bs2.min.js"></script>
    <!-- page specific plugin scripts -->
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script type="${pageContext.request.contextPath}/statics/text/javascript" src="js/H-ui.js"></script>
    <script type="${pageContext.request.contextPath}/statics/text/javascript" src="js/H-ui.admin.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/layer/layer.js" type="text/javascript" ></script>
    <script src="${pageContext.request.contextPath}/statics/assets/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/Widget/zTree/js/jquery.ztree.all-3.5.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/js/lrtk.js" type="text/javascript" ></script>
    <title>分类管理</title>
</head>

<body>
<div class="page-content clearfix">
    <div class="sort_style">
        <div class="border clearfix">
       <span class="l_f">
        <a href="${pageContext.request.contextPath}/business/specifications/add" title="添加分类" class="btn btn-warning Order_form"><i class="icon-plus"></i>添加规格</a>
        <a href="javascript:ovid()" class="btn btn-danger"><i class="icon-trash"></i>批量删除</a>
       </span>
        </div>
        <div class="search_style" style="margin: 10px 0px;">
            <form action="${pageContext.request.contextPath}/business/specifications/list?pageindex=1" method="get" class="form-inline">
                <input type="hidden" name="pageindex" value="1"/>
                <div class="form-group">
                    <label>规格名称:</label>
                    <input type="text" name="sname" value="${sname}">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-info">查询</button>
                </div>
            </form>
        </div>
        <div class="sort_list">
            <table class="table table-striped table-bordered table-hover" id="sample-table">
                <thead>
                <tr>
                    <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                    <th width="100px">规格id</th>
                    <th width="100px">规格名称</th>
                    <th width="250px">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="mc" items="${pageInfo.list}">
                    <tr>
                        <td width="25px"><label><input type="checkbox" class="ace" name="inputdel" value="${mc.sid}" ><span class="lbl"></span></label></td>
                        <td width="80px">${mc.sid}</td>
                        <td width="250px"><u style="cursor:pointer" class="text-primary" onclick="">${mc.sname}</u></td>
                        <td class="td-manage">
                                <%--                            <a onClick="member_stop(this,'10001')"  href="javascript:;" title="停用"  class="btn btn-xs btn-success"><i class="icon-ok bigger-120"></i></a>--%>
                            <a title="编辑" href="${pageContext.request.contextPath}/business/specifications/update?id=${mc.sid}"  class="btn btn-xs btn-info" ><i class="icon-edit bigger-120"></i></a>
                            <a title="删除" href="javascript:;"  onclick="member_del(this,${mc.sid})" class="btn btn-xs btn-warning" ><i class="icon-trash  bigger-120"></i></a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <div class="container text-center">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isFirstPage}">
                                <a href="${pageContext.request.contextPath}/business/specifications/list?pageindex=1" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/business/specifications/list?pageindex=${pageInfo.prePage}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                    <%--el标签的其中一个for循环--%>
                    <c:choose>
                        <c:when test="${pageInfo.pages<=10}">
                            <c:set var="startpage" value="1"></c:set>
                            <c:set var="endpage" value="${pageInfo.pages}"></c:set>
                        </c:when>
                        <c:otherwise>
                            <c:choose>
                                <c:when test="${pageInfo.pageNum<10}">
                                    <c:set var="startpage" value="1"></c:set>
                                    <c:set var="endpage" value="10"></c:set>
                                </c:when>
                                <c:when test="${pageInfo.pages-pageInfo.pageNum<=5}">
                                    <c:set var="startpage" value="${pageInfo.pageNum-10}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageNum}"></c:set>
                                </c:when>
                                <c:otherwise>
                                    <c:set var="startpage" value="${pageInfo.pageNum-4}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageNum+5}"></c:set>
                                </c:otherwise>
                            </c:choose>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach begin="${startpage}" end="${endpage}" step="1" varStatus="status">
                        <c:choose>
                            <c:when test="${status.index==pageInfo.pageNum}">
                                <li class="active">
                            </c:when>
                            <c:otherwise>
                                <li>
                            </c:otherwise>
                        </c:choose>
                        <a href="${pageContext.request.contextPath}/business/specifications/list?pageindex=${status.index}">${status.index}</a></li>
                    </c:forEach>
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isLastPage}">
                                <a href="${pageContext.request.contextPath}/business/specifications/list?pageindex=${pageInfo.pages}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/business/specifications/list?pageindex=${pageInfo.nextPage}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
<script>

    $(function () {
        //全选
        $("#selectAll").on("change",function () {
            // $("input[name='inputdel']").each(function () {
            //     $(this).prop("checked",$("#selectAll").prop("checked"))
            // })
            $("input[name='inputdel']").prop("checked",$(this).prop("checked"))
        })
    })

    function member_del(target,id) {
        var isok = confirm("确认要删除吗？");
        if (isok){
            $.getJSON("${pageContext.request.contextPath}/business/specifications/del",{"id":id},function (e) {
                if (e.code==200){
                    alert(e.message);
                    /*删除dom元素*/
                    $(target).parent().parent().remove();
                }else {
                    alert(e.message)
                    // console.log(e)
                }
            })
        }
    }

    function ovid() {
        var list = $(".ace[name='inputdel']:checked");
        var params = list.toArray();
        for (var i=0;list.length>i;i++){
            params[i]=list[i].value;
        }

        $.getJSON("${pageContext.request.contextPath}/business/specifications/delbyids",{"ids":params},function (e) {
            if (e.code==200){
                alert(e.message);
                /*删除dom元素*/
                window.location.href="${pageContext.request.contextPath}/business/specifications/list?pageindex=1"
            }else {
                alert(e.message)
                // console.log(e)
            }
        })

    }
</script>

